package xfsale.util;

import java.lang.reflect.Field;

public class ObjectUtil {

    public static boolean hasProperty(Object object, String propertyName) {
        try {
            Field field = object.getClass().getField(propertyName);
            return field != null;
        } catch (Exception ex) {
        }
        return false;
    }

    public static void setProperty(Object object, String propertyName, Object propertyValue) {
        try {
            Field field = object.getClass().getField(propertyName);
            if (field == null) {
                return;
            }

            field.set(object, propertyValue);
        } catch (Exception ex) {
        }
    }

    public static Object getProperty(Object object, String propertyName) {
        try {
            Field field = object.getClass().getField(propertyName);
            if (field == null) {
                return null;
            }

            return field.get(object);
        } catch (Exception ex) {
        }

        return null;
    }

    public static void copyProperty(Object source, Object target) {
        
    }
}
